/*
 * @Author: liuying 247220246@qq.com
 * @Date: 2024-12-06 17:15:31
 * @LastEditors: liuying 247220246@qq.com
 * @LastEditTime: 2024-12-10 10:54:40
 * @FilePath: \vite-book-react\src\routers\index.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import React from 'react';
import { useRoutes, Navigate } from 'react-router-dom';
import Home from '@/pages/home/index';
import Shelf from '@/pages/shelf/index';
import Ranking from '@/pages/ranking/index';
import Category from '@/pages/category/index';
import Search from '@/pages/search/index';
import Booklist from '@/pages/bookList/index';
import Detail from '@/pages/detail/index';
import Chapter from '@/pages/chapter/index';

const Router: React.FC = React.memo(() => {
  const element = useRoutes([
    {
      path: '/',
      element: <Home />,
    },
    {
      path: '/shelf',
      element: <Shelf />,
    },
    {
      path: '/ranking',
      element: <Ranking />,
    },
    {
      path: '/category',
      element: <Category />,
    },
    {
      path: '/search',
      element: <Search />,
    },
    {
      path: '/book-list/:key',
      element: <Booklist />,
    },
    {
      path: '/book/:id',
      element: <Detail />,
    },
    {
      path: '/book/:bookId/:chapterId',
      element: <Chapter />,
    },
    {
      path: '*',
      element: <Navigate to="/" />,
    },
  ]);

  return element;
});

export default Router;